/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package thinkinginjava.svn.io.binary;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author evenpet
 */
public class BinaryFile {

    public static byte[] read(File bFile) {
        BufferedInputStream bf = null;
        try {
            bf = new BufferedInputStream(new FileInputStream(bFile));
            byte[] data = new byte[bf.available()];
            bf.read(data);
            return data;
        } catch (FileNotFoundException ex) {
            Logger.getLogger(BinaryFile.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            ex.printStackTrace();
        } finally {
            try {
                bf.close();
            } catch (IOException ex) {
                Logger.getLogger(BinaryFile.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return null;
    }

    public static byte[] read(String bFile) {
        return read(new File(bFile).getAbsoluteFile());
    }
}
